class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int, vector<int>, greater<int>> memo;
        for(int i = 0; i < k; i++)
        {
            memo.push(nums[i]);
        }
        for(int i = k; i < nums.size(); i++)
        {
            if(nums[i] <= memo.top()) continue;
            memo.pop();
            memo.push(nums[i]);
        }
        return memo.top();
    }
};
